package com.honeyms.project.blog.blogzanusercontent.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.honeyms.framework.aspectj.lang.annotation.Log;
import com.honeyms.framework.aspectj.lang.enums.BusinessType;
import com.honeyms.project.blog.blogzanusercontent.domain.BlogZanUserContent;
import com.honeyms.project.blog.blogzanusercontent.service.IBlogZanUserContentService;
import com.honeyms.framework.web.controller.BaseController;
import com.honeyms.framework.web.domain.AjaxResult;
import com.honeyms.common.utils.poi.ExcelUtil;
import com.honeyms.framework.web.page.TableDataInfo;

/**
 * 用户点赞帖子Controller
 * 
 * @author honeyms
 * @date 2020-10-16
 */
@Controller
@RequestMapping("/blog/blogzanusercontent")
public class BlogZanUserContentController extends BaseController
{
    private String prefix = "blog/blogzanusercontent";

    @Autowired
    private IBlogZanUserContentService blogZanUserContentService;

    @RequiresPermissions("blog:blogzanusercontent:view")
    @GetMapping()
    public String blogzanusercontent()
    {
        return prefix + "/blogzanusercontent";
    }
   

    /**
     * 查询用户点赞帖子列表
     */
    @RequiresPermissions("blog:blogzanusercontent:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(BlogZanUserContent blogZanUserContent)
    {
        startPage();
        List<BlogZanUserContent> list = blogZanUserContentService.selectBlogZanUserContentList(blogZanUserContent);
        return getDataTable(list);
    }

    /**
     * 导出用户点赞帖子列表
     */
    @RequiresPermissions("blog:blogzanusercontent:export")
    @Log(title = "用户点赞帖子", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(BlogZanUserContent blogZanUserContent)
    {
        List<BlogZanUserContent> list = blogZanUserContentService.selectBlogZanUserContentList(blogZanUserContent);
        ExcelUtil<BlogZanUserContent> util = new ExcelUtil<BlogZanUserContent>(BlogZanUserContent.class);
        return util.exportExcel(list, "blogzanusercontent");
    }

    /**
     * 新增用户点赞帖子
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存用户点赞帖子
     */
    @RequiresPermissions("blog:blogzanusercontent:add")
    @Log(title = "用户点赞帖子", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(BlogZanUserContent blogZanUserContent)
    {
        return toAjax(blogZanUserContentService.insertBlogZanUserContent(blogZanUserContent));
    }

    /**
     * 修改用户点赞帖子
     */
    @GetMapping("/edit/{userId}")
    public String edit(@PathVariable("userId") Long userId, ModelMap mmap)
    {
        BlogZanUserContent blogZanUserContent = blogZanUserContentService.selectBlogZanUserContentById(userId);
        mmap.put("blogZanUserContent", blogZanUserContent);
        return prefix + "/edit";
    }

    /**
     * 修改保存用户点赞帖子
     */
    @RequiresPermissions("blog:blogzanusercontent:edit")
    @Log(title = "用户点赞帖子", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(BlogZanUserContent blogZanUserContent)
    {
        return toAjax(blogZanUserContentService.updateBlogZanUserContent(blogZanUserContent));
    }

    /**
     * 删除用户点赞帖子
     */
    @RequiresPermissions("blog:blogzanusercontent:remove")
    @Log(title = "用户点赞帖子", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(blogZanUserContentService.deleteBlogZanUserContentByIds(ids));
    }
}
